#ifndef __USER_I2C_H
#define __USER_I2C_H

#ifdef __cplusplus
extern "C" {
#endif

#include "stdint.h"
#include "ti_msp_dl_config.h"
#include "string.h"
#include "stdbool.h"
#include "delay.h"


/********************宏定义********************/
#define I2C_RXFIFO_NOT_EMPTY 0x00000080U
#define I2C_TXFIFO_IS_EMPTY 0x00000100U
#define I2C_OK 		0
#define I2C_ERROR 	-1  //i2c通信时序不完整
#define I2C_FAILED 	-2  //i2c写入/读取失败
#define I2C_BUSY 	-3    //i2c总线忙
#define I2C_SERIAL_NUMBER_OUT_OF_RANGE -4 //i2c句柄超出范围，如果可用的i2c数量大于2，修改which_i2c_inst函数
#define I2C_DATA_COUNT_ERROR -5 //发送/读取的数据数量为0或大于 I2C_BUFFER_SIZE

#define I2C_REG_ADDR_NONE UINT16_MAX

/*可配置项*/
#define I2C_NUM 2
#define I2C_BUFFER_SIZE 512


/********************全局函数声明********************/
void i2c_dma_init();

int8_t i2c_write(I2C_Regs *this_i2c,uint8_t slave_addr,uint16_t reg_addr,uint8_t* data,uint16_t count);
int8_t i2c_write_one(I2C_Regs *this_i2c,uint8_t slave_addr,uint8_t reg_addr,uint8_t data);

int8_t i2c_read(I2C_Regs *this_i2c,uint8_t slave_addr,uint16_t reg_addr,uint8_t* data,uint16_t count);
int8_t i2c_read_one(I2C_Regs *this_i2c,uint8_t slave_addr,uint8_t reg_addr,uint8_t* data);

#ifdef __cplusplus
}
#endif

#endif